<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>QUnit Example</title>
  <link rel="stylesheet" href="../qunit.css">
</head>
<body>
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  <script src="../../../WebContent/node_modules/underscore/underscore.js"></script>
  <script src="../qunit.js"></script>
  <script src="../../../WebContent/client/js/lib/class.js"></script>
  <script>
  	//mock out require
  	var AStar;
  	var Pathfinder;
	var define = function (possibleFunction1, possibleFunction2) {
		if (possibleFunction1 instanceof Function){
			AStar = possibleFunction1();
		}else if(possibleFunction2 instanceof Function){
			//var genPathfinder = possibleFunction2(AStar);
			//Pathfinder = genPathfinder(AStar);
			Pathfinder = possibleFunction2;
		}
	};
  </script>
  <script src="../../../WebContent/client/js/lib/astar.js"></script>
  <script src="../../../WebContent/client/js/pathfinder.js"></script>
  <script src="normalGrid.js"></script>
  <script>
  	var findPathTest = function (gridX,gridY,x,y,findIncomplete) {
  		//findPath: function(grid, entity, x, y, findIncomplete)
		var valid;
		var entity = {};
		entity.gridX = gridX;
		entity.gridY= gridY;
		var myPathfinder = new Pathfinder(AStar);
		var myproto = myPathfinder.prototype;
		myproto.init(172,314);
		myproto.initBlankGrid_();
		var path = myproto.findPath(normalGrid,entity,x,y,findIncomplete);
		return path;
  	};
  </script>
  
  <script>
  	$(document).ready(function(){

  		
		module("random test");
		
		test("test 1a", function (){
			var path = findPathTest(102,155,53,122,true);
			ok(path.length > 0,"partial path returned");
		});
		
		test("test 2", function (){
			var path = findPathTest(80,113,121,211,false);
			ok(path.length === 0,"no partial path returned");
		});
		
		test("test 3", function (){
			var path = findPathTest(167,272,136,78,true);
			ok(path.length >= 227,"a path of at least size 227 was returned."+path.length);
		});
		
		test("test 4", function (){
			var path = findPathTest(33,255,55,42,false);
			ok(path.length >= 236,"a path of at least size 236 was returned."+path.length);
		});
		
		test("test 5", function (){
			var path = findPathTest(34,78,125,287,true);
			ok(path.length === 0,"no partial path returned");
		});
		
	});
  </script>
</body>
</html>